<include file="public@header"/>
</head>
<body>
<div class="wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a>订单列表</a></li>
        <li><a>订单量 {$total}</a></li>
        <li><a>带审核 {$total_2}</a></li>
        <li><a>待处理 {$total_3}</a></li>
        <li><a>已处理 {$total_4}</a></li>
    </ul>
    <form class="well form-inline margin-top-20" method="post" action="{:url('order/index')}">
        关键字：
        <input class="form-control" type="text" name="keyword" style="width: 200px;" value="{:input('request.keyword')}" placeholder="">
        状态：
        <select class="form-control" name="status">
            <option value="">---请选择---</option>
            <option value="-1" <if input('status') != '' && input('status') == '-1'>selected</if> >已拒绝</option>
            <option value="0" <if input('status') != '' && input('status') == '0'>selected</if> >待审核</option>
            <option value="1" <if input('status') != '' && input('status') == '1'>selected</if> >待处理</option>
            <option value="2" <if input('status') != '' && input('status') == '2'>selected</if> >已处理</option>
        </select>
        工厂：
        <select class="form-control" name="factory">
            <option value="">---请选择---</option>
            <foreach name="factory" item="vo">
                <option value="{$vo.fnumber}" <if input('factory') == $vo.fnumber>selected</if> >{$vo.fname}</option>
            </foreach>
        </select>
        业务员：
        <select class="form-control" name="salesman">
            <option value="">---请选择---</option>
            <foreach name="salesman" item="vo">
                <option value="{$vo.fempnumber}" <if input('salesman') == $vo.fempnumber>selected</if> >{$vo.name}</option>
            </foreach>
        </select>
        下单时间：
        <input class="form-control js-bootstrap-date" name="start_time" value="{:input('start_time')}" autocomplete="off">
        -
        <input class="form-control js-bootstrap-date" name="end_time" value="{:input('end_time')}" autocomplete="off">
        <input type="submit" class="btn btn-primary" value="搜索"/>
        <a class="btn btn-danger" href="{:url('order/index')}">清空</a>
    </form>
    <form method="post" class="js-ajax-form">
        <table class="table table-hover table-bordered">
            <thead>
            <tr>
                <th>订单号</th>
                <th>销售组织</th>
                <th>订单类型</th>
                <th>销售类型</th>
                <th>销售人员</th>
                <th>客户</th>
                <th>发货组织</th>
                <th>收货方式</th>
                <th>支付方式</th>
                <th>支付账期</th>
                <th>发货日期</th>
                <th>总重量</th>
                <th>总价</th>
                <th>下单时间</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <php>
                $status_list = ['-1'=>'已拒绝','0'=>'待审核','1'=>'待处理','2'=>'已处理'];
                $sale_type_text = ['1'=>'直销','2'=>'经销'];
            </php>
                <foreach name="list" item="vo">
                <tr>
                    <td>{$vo.order_no}</td>
                    <td>{:factory_name($vo.sale_number)}</td>
                    <td><if $vo.yushou_id>预售单转<else/>正常单</if></td>
                    <td>{$sale_type_text[$vo.sale_type]}</td>
                    <td>{$vo.staff_name}({$vo.staff_number})</td>
                    <td>{$vo.customer_name}({$vo.customer_number})</td>
                    <td>{$vo.factory_name}</td>
                    <td><if $vo.type == '自提'>{$vo.type}<else/>{$vo.receiving_address}</if></td>
                    <td>{$vo.pay_type}</td>
                    <td>{$vo.pay_account}</td>
                    <td>{$vo.fahuo_date}</td>
                    <td>{$vo.total_weight}</td>
                    <td>{$vo.total_price}</td>
                    <td>{:date('Y-m-d H:i',$vo.create_time)}</td>
                    <td>{$status_list[$vo.status]}</td>
                    <td>
                        <a class="btn btn-xs btn-primary" href="javascript:parent.openIframeLayer('{:url('order/details',array('id'=>$vo['id']))}','详情',{'area':['600px','80%']});">详情</a>
                        <!-- <a class="btn btn-xs btn-primary" href="javascript:parent.openIframeLayer('{:url('customer_service/edit',array('id'=>$vo['id']))}','详情',{'area':['800px','80%']});">编辑</a> -->
                        <!-- <a class="btn btn-xs btn-primary" href="">合同下载</a>
                        <a class="btn btn-xs btn-primary" href="javascript:parent.openIframeLayer('{:url('customer_service/contract_upload',array('id'=>$vo['id']))}','详情',{'area':['600px','80%']});">合同回传</a>
                        <a class="btn btn-xs btn-primary" href="javascript:parent.openIframeLayer('{:url('customer_service/power_upload',array('id'=>$vo['id']))}','详情',{'area':['600px','80%']});">上传委托书</a> -->
                    </td>
                </tr>
                </foreach>
            </tbody>
        </table>
        <div class="pagination">{$page}</div>
    </form>
</div>
<script src="__STATIC__/js/admin.js"></script>
<script src="__STATIC__/layui/layui.js"></script>
<script type="text/javascript">
$('select[name=working]').change(function(){
    var working = $(this).val();
    console.log(working);
    $.ajax({
        type: 'post',
        url: '{:url("customer_service/working")}',
        data: {working:working},
        success:function(res){

        }
    });
});

layui.use(['layer'],function(){
    var layer = layui.layer;

    $('.grab_orders').click(function(){
        $.ajax({
            type: 'get',
            url: '{:url("customer_service/grab_orders")}',
            success:function(res){
                if(res.code == 1){
                    layer.open({
                        type: 2,
                        title: '订单处理',
                        area: ['600px','80%'],
                        content: '{:url("customer_service/grab_orders")}'
                    });
                }else{
                    layer.msg(res.msg);
                }
            }
        })
    });
});

</script>
</body>
</html>